<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title th:text="${session.title}">123</title>
    <link th:replace="common/header"/>
    <link rel="stylesheet" th:href="@{/css/ace-skins.min.css}"/>
    <script type="text/javascript">
        function findpwd() {
            var userId = $("#id").val();
            var qes1 = $("#qes1").val();
            var qes2 = $("#qes2").val();
            var ans1 = $("#ans1").val();
            var ans2 = $("#ans2").val();
            var qe1 = $("#qes1err");
            qe1.html("");
            var qe2 = $("#qes2err");
            qe2.html("");
            var ae1 = $("#ans1err");
            ae1.html("");
            var ae2 = $("#ans2err");
            ae2.html("");

            if (qes1 === '') {
                qe1.html("问题1不能为空");
                return;
            }
            if (qes2 === '') {
                qe2.html("问题2不能为空");
                return;
            }
            if (ans1 === '') {
                ae1.html("回答1不能为空");
                return;
            }
            if (ans2 === '') {
                ae2.html("回答2不能为空");
                return;
            }
            if (qes1 === qes2) {
                qe1.html("两个问题不能一样");
                return;
            }
            if (ans1 === ans2) {
                ae1.html("两个回答不能一样");
                return;
            }
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "/findpwd",
                data: "id=" + userId + "&qes1=" + qes1 + "&qes2=" +
                qes2 + "&ans1=" + ans1 + "&ans2=" + ans2,
                success: function (data) {
                    if (data.msg === 'ok') {
                        showTip('tip', '密码找回设置成功', 4000);
                        $("#qes1").val("");
                        $("#qes2").val("");
                        $("#ans1").val("");
                        $("#ans2").val("");
                    } else {
                        showTip('tip', '密码找回设置失败', 4000);
                    }
                }
            });
        }
    </script>
</head>
<body class="navbar-fixed">
<div th:replace="common/top"></div>
<div class="container-fluid main_bg" id="main-container">
    <a id="menu-toggler" href="#"><span></span></a>
    <div th:replace="common/menu"></div>
    <div id="main-content" class="clearfix">
        <div id="page-content" class="clearfix">
            <div th:replace="common/title"></div>
            <div class="row-fluid">
                <!--page-content-->
                <div class="span12">
                    <div class="login-container">
                        <div class="space-6"></div>
                        <div class="row-fluid">
                            <div class="position-relative">
                                <div id="signup-box" class="visible widget-box no-border">
                                    <div class="widget-body">
                                        <div class="widget-main">
                                            <h4 class="header green lighter bigger"><em class="icon-group green"></em>个人中心
                                            </h4>
                                            <div class="space-6"></div>
                                            <p style="color: #ccc; ">设置密码找回</p>
                                            <input type="hidden" name="id" id="id" th:value="${session.footUser.id}"/>
                                            <fieldset>
                                                <label> <span class="block input-icon input-icon-right"> <input
                                                        id="qes1" name="qes1" class="span12" type="text"
                                                        placeholder="问题"/> <em class="icon-question"></em> </span>
                                                    <span><span id="qes1err" style="color:red"></span></span> </label>
                                                <label> <span class="block input-icon input-icon-right"> <input
                                                        id="ans1" name="ans1" class="span12" type="text"
                                                        placeholder="答案"/> <em class="icon-pencil"></em> </span>
                                                    <span><span id="ans1err" style="color:red"></span></span> </label>
                                                <label> <span class="block input-icon input-icon-right"> <input
                                                        id="qes2" name="qes2" class="span12" type="text"
                                                        placeholder="问题"/> <em class="icon-question"></em> </span>
                                                    <span><span id="qes2err" style="color:red"></span></span> </label>
                                                <label> <span class="block input-icon input-icon-right"> <input
                                                        id="ans2" name="ans2" class="span12" type="text"
                                                        placeholder="答案"/> <em class="icon-pencil"></em> </span>
                                                    <span><span id="ans2err" style="color:red"></span></span> </label>
                                                <div class="space-24"></div>
                                                <div class="row-fluid">
                                                    <button type="reset" class="span6 btn btn-small"><em
                                                            class="icon-refresh"></em>重置
                                                    </button>
                                                    <button type="button" onclick="findpwd();"
                                                            class="span6 btn btn-small btn-success"> 提交<em
                                                            class="icon-arrow-right icon-on-right"></em></button>
                                                </div>
                                            </fieldset>
                                        </div>
                                        <div class="toolbar center">
                                            <a th:href="@{/index}" class="back-to-login-link"> <em
                                                    class="icon-arrow-left"></em> 返回首页 </a>
                                        </div>
                                    </div>
                                    <!--/widget-body-->
                                </div>
                                <!--/signup-box-->
                            </div>
                            <!--/position-relative-->
                        </div>
                    </div>
                </div>
                <!--/span-->
                <!--/#page-content-->
            </div>
        </div>
        <div th:replace="common/skin :: skin"></div>
    </div>
    <!--/#main-content-->
</div>
<!--/.fluid-container#main-container-->
<div th:replace="common/js"></div>
</body>
</html>